package db

import (
	"fmt"
	"ginTemplate/config"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB
var err error

func init() {
	dsn := config.GetConfig("database.user") + ":" + config.GetConfig("database.password") + "@tcp(" + config.GetConfig("database.url") + ":" + config.GetConfig("database.port") + ")/" + config.GetConfig("database.name") + "?charset=utf8mb4&parseTime=True&loc=Local"
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Println(err)
	}
}
